export default function dateToString(date){
	console.log("初始化date:",date);

	if(date != null && date != ""  &&  date != undefined){
    date = new Date(date);
		let year = date.getFullYear();
		let month =(date.getMonth() + 1).toString();
		let day = (date.getDate()).toString();

		let hours = date.getHours();

		let minutes= date.getMinutes();
		let seconds= date.getSeconds();
		console.log(minutes);

		if (month.length == 1) {
		    month = "0" + month;
		}
		if (day.length == 1) {
		    day = "0" + day;
		}
		if (hours<10) {
		    hours = "0" + hours;
		}
		if (minutes<10) {
		    minutes = "0" + minutes;
				console.log("minutes:",minutes)
		}
		if (seconds<10) {
		    seconds = "0" + seconds;
		}


		let dateTime = year + "-" + month + "-" + day + " "+ hours + ":" + minutes + ":"+ seconds;
		console.log(dateTime);
		return dateTime;
	}else{
		return date;
	}


}





// dateToString: function(date){
//   var year = date.getFullYear();
//   var month =(date.getMonth() + 1).toString();
//   var day = (date.getDate()).toString();
//   if (month.length == 1) {
//       month = "0" + month;
//   }
//   if (day.length == 1) {
//       day = "0" + day;
//   }
//   var dateTime = year + "-" + month + "-" + day;
//   return dateTime;
// },
